window.onload=function () {
    var app = new Vue({
        el: "#app",
        data: {
            pagination: {
                total: 0, //总记录数
                pageSize: 10, //每页的记录数
                pageNum: 1, //当前页码
            },
            articlearray:[],//所有未审核文章
            lookarticle:false,//控制查看未审核文章
            article:{
                a_content:"",
                a_title:"",
                tid:"",
                state:"",
                reasons:"",
                aid:""
            },
            updatearticle:false,//控制修改未审核文章
            toucharray:[],//所以类型
            deletearticle:false,//删除弹出框,
        },
        methods: {
            inisarticleno(){
                //初始化数据
                methodaxios.get(null,"/article/listno?currentPage="+this.pagination.pageNum+"&pageSize="+this.pagination.pageSize,rep=>{
                   window.console.log("==============================================")
                    window.console.log(rep.data.data)
                    this.articlearray=rep.data.data;
                    this.pagination.total=rep.data.count;
                });
                methodaxios.get(null,"/touch/listarticle",rep=>{
                    window.console.log(rep)
                    this.toucharray=rep.data
                });
            }, //当前页发送改变
            findBlogPageList(page) {
                //页数改变
                this.pagination.pageNum = page;
                this.inisarticleno();
            }, //每页大小发送改变
            sizeChange(size) {
                this.pagination.pageSize = size; //当前页显示多少
                this.pagination.pageNum = 1;
                this.inisarticleno();
            },
            tableRowClassName({row, rowIndex}) {//表格斑马线
                if (rowIndex%2==1) {
                    return 'warning-row';
                } else{
                    return 'success-row';
                }
            },
            wantlook(row){//查看当前文章
                window.console.log("未审核文章")
                window.console.log(row)
               var E = window.wangEditor
                var editor = new E('#editor')
                editor.create()
                this.lookarticle=true
                //this.article.a_content=row.a_content;
                this.article.a_title=row.a_title;
                editor.$textElem.attr('contenteditable', false)
                editor.txt.html('<p>' +row.a_content+'</p>' );
            },
            confirmupdatea(){//确定修改文章
                if(isBlank(this.article.state)){
                    layer.msg("请指定状态");
                    return false;
                }
                if(isBlank(this.article.reasons)){
                    layer.msg("请填写文章描述");
                    return false;
                }
                if(isBlank(this.article.tid)){
                    layer.msg("请指定文章类型");
                    return false;
                }
                methodaxios.post("/article/updateno",this.article,rep=>{
                    if(rep.data.code==="200"){
                        this.article.tid=""
                        this.article.reasons=""
                        this.article.state=""
                        layer.msg("修改成功");
                        this.updatearticle=false
                        this.inisarticleno();
                    }
                });
            },
            updatea(row){//点击修改文章
                this.updatearticle=true
                var E = window.wangEditor
                var editor = new E('#updateeditor')
                editor.create()
                //this.article.a_content=row.a_content;
                this.article.a_title=row.a_title;
                this.article.aid=row.aid;
                editor.$textElem.attr('contenteditable', false)
                editor.txt.html('<p>' +row.a_content+'</p>' );
            },
            confirmdeletea(){//确定删除
                methodaxios.get({aid:this.article.aid},"/article/deleteno",rep=>{
                    this.deletearticle=false
                    layer.msg("删除成功");
                    this.inisarticleno();
                });
            },
            mydeletes(aid,title){//点击删除弹出框
                this.deletearticle=true
                this.article.a_title=title;
                this.article.aid=aid;
            }

        },mounted(){
            this.inisarticleno();
        },
        filters:{
            mytime(value){
                var dateee = new Date( value).toJSON();
                return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
            },//状态(0 伪删除 1审核中 2通过 3未通过)
            mystate(value){
                if(value=="0"){
                    return "已删除"
                }else if(value=="1"){
                    return "审核中"
                }else if(value=="2"){
                    return "通过"
                }else if(value=="3"){
                    return "未通过"
                }
            }
        }

    })
}
